setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "ERROR : ".$e->getMessage(); } $sql = $DBcon->prepare("select sn from hca_app1 ORDER BY sn DESC LIMIT 1"); $sql->execute() ; $row = $sql->FETCH(PDO::FETCH_ASSOC) ; $id = $row['sn'] ; $t=time(); $newid = $id + 1 ; $prfix = 'CBAPPLICANT'.$t.'_0' ; $newuserid = $prfix.$newid ; //$pwd = $newid.'xchangex' ; return $newuserid ; //return $pwd ; } /* Add this code to the end of your PHP programs, and you can then call it for each user input to sanitize, like this: $var = sanitizeString($_POST['user_input']); Or, when you have an open MySQL connection and a mysqli connection object (in this case, called $connection): $var = sanitizeMySQL($connection, $_POST['user_input']); */ ?>